﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using ThresholdAssistant.DataContract.Result;
using ThresholdAssistant.WebAPI.Models;
using ThresholdAssistant.WebAPI.Service;

namespace ThresholdAssistant.WebAPI.Controllers
{
    /// <summary>
    /// 微信控制器
    /// </summary>
    [Route("api/wechat")]
    public class WeChatController : BaseController
    {
        /// <summary>
        /// 标签服务
        /// </summary>
        public WeChatService WeChatService { get; set; }


        /// <summary>
        /// 获取token
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost("get-accesstoken")]
        [AllowAnonymous]
        public async Task<ContractResult> GetTagtypeListAsync()
        {
            return await WeChatService.GetAccessTokenAsync();
        }

        /// <summary>
        /// 发送模版消息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost("send-templatemessage")]
        [AllowAnonymous]
        public async Task<ContractResult> SendTemplateMessageAsync(SendTemplateMessageParam param)
        {
            return await WeChatService.SendTemplateMessageAsync(param);
        }

    }
}